import {putAction} from "@/api/manage";
// 前提 要导入JeecgListMixin

export const BoneRecommendMixin = {
  methods: {
    handleIsRecommend(index) {
      if (!this.url.isRecommend) {
        this.$message.error("请设置url.isRecommend!");
        return;
      }
      if (index == null || index === undefined) {
        this.$message.error("请传递索引值");
        return;
      }
      this.dataSource[index].isRecommend === 0 ? this.dataSource[index].isRecommend = 1 : this.dataSource[index].isRecommend = 0;
      putAction(this.url.isRecommend + "/" + this.dataSource[index].id + "/" + this.dataSource[index].isRecommend).then(res => {
        if (res.code === 200) {
          this.$notification.success({message: "提示信息", duration: 2, description: res.message});
        } else {
          this.$notification.error({message: "提示信息", duration: 2, description: res.message});
        }
      });
    },
  }
};